// 如果没有通过拦截器配置域名的话，可以在这里写上完整的URL(加上域名部分)
let sendSmsUrl = '/api/send/sms';
let mobileLoginUrl = '/api/mobile/login';
let wechatInfoSaveUrl = '/api/user/save/info';
let wechatLoginUrl = '/api/wechat/mini/login';
let userInfoByTokenUrl = '/api/user/info';

let getGenerateLinkUrl = '/api/generate/link';

let extOrderListUrl = "/api/order";

let financeListUrl = "/api/user/wallet/log";

let myTeamUrl = "/api/user/my/team";
let posterUrl = "/api/user/share/image";

let wechatBindMobileUrl = "/api/user/bind/wechat/mobile";

let withdrawalUrl = "/api/cash";
let withdrawalLogUrl = "/api/cash/list";
let bindAlipayUrl = "/api/user/bind/alipay";
let alipayInfoUrl = "/api/user/alipay/info";
 
 let bindMobileUrl = "/api/user/bind/mobile";
 
 let cashTypeUrl = "/api/cash/type";
 
 /**
  * 商城
  */ 
 let indexConfigUrl = "/api/home/page";
 let goodsListUrl = "/api/goods/list";
 let goodsInfoUrl = "/api/goods/detail";
 let classifyUrl = "/api/goods/classify";
 
 let generateLinkUrl = "/api/goods/generate/link";
 let searchGenerateLinkUrl = "/api/goods/search/generate/link";
 
 let goodsSearchUrl = "/api/goods/search";
 let goodsSearchDetailUrl = "/api/goods/search/detail";
 let shareImageUrl = "/api/goods/share/image";
 
 /**
  * 收获地址
  */
 let addressListUrl = "/api/user/address/list";
 let addressEditUrl = "/api/user/address/edit";
 let addressAddUrl = "/api/user/address/add";
 let addressDelUrl = "/api/user/address/del";
 
 /**
  * 订单
  */
 let createOrderUrl = "/api/order/now/by";
 let updateOrderAddressUrl = "/api/order/edit/address";
 let orderSubmitUrl = "/api/order/submit";
 let paymentUrl = "/api/order/payment";
 let orderListUrl = "/api/order/self";
 let cancelOrderUrl = "/api/order/cancel";
 
 /**
  * 充值
  */
 let rechangeMobileConfigUrl = "/api/mobile/charge/config";
 let rechangeCreateOrderUrl = "/api/order/mobile/charge";
 let rechangePaymentUrl = "/api/order/mobile/charge/submit";
 
 /* 拼团订单 */
 let myGroupOrderUrl = '/api/order/groupon/list'

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	let sendSms = (params = {}) => vm.$u.post(sendSmsUrl, params);
	let mobileLogin = (params = {}) => vm.$u.post(mobileLoginUrl, params);
	let wechatInfoSave = (params = {}) => vm.$u.post(wechatInfoSaveUrl, params);
	let wechatLogin = (params = {}) => vm.$u.post(wechatLoginUrl, params);
	let userInfoByToken = (params = {}) => vm.$u.get(userInfoByTokenUrl, params);
	
	let getGenerateLink = (params = {}) => vm.$u.post(getGenerateLinkUrl, params);
	let extOrderList = (params = {}) => vm.$u.get(extOrderListUrl, params);
	
	let financeList =  (params = {}) => vm.$u.get(financeListUrl, params);
	let myTeam = (params = {}) => vm.$u.get(myTeamUrl, params);
	let poster = (params = {}) => vm.$u.get(posterUrl, params);
	let wechatBindMobile = (params = {}) => vm.$u.post(wechatBindMobileUrl, params);
	let withdrawal = (params = {}) => vm.$u.post(withdrawalUrl, params);
	let withdrawalLog = (params = {}) => vm.$u.get(withdrawalLogUrl, params);
	
	let bindAlipay = (params = {}) => vm.$u.post(bindAlipayUrl, params);
	let alipayInfo = (params = {}) => vm.$u.get(alipayInfoUrl, params);
	let bindMobile = (params = {}) => vm.$u.post(bindMobileUrl, params);
	
	let goodsList  = (params = {}) => vm.$u.get(goodsListUrl, params);
	let goodsInfo = (params = {}) => vm.$u.get(goodsInfoUrl, params);
	let classify = (params = {}) => vm.$u.get(classifyUrl, params);
	
	let generateLink = (params = {}) => vm.$u.get(generateLinkUrl, params);
	let searchGenerateLink = (params = {}) => vm.$u.get(searchGenerateLinkUrl, params);
	
	let goodsSearch = (params = {}) => vm.$u.get(goodsSearchUrl, params);
	let goodsSearchDetail = (params = {}) => vm.$u.get(goodsSearchDetailUrl, params);
	let shareImage = (params = {}) => vm.$u.get(shareImageUrl, params);
	let cashType = (params = {}) => vm.$u.get(cashTypeUrl, params);
	
	let indexConfig = (params = {}) => vm.$u.get(indexConfigUrl, params);
	
	
	let addressList = (params = {}) => vm.$u.get(addressListUrl, params);
	let addressEdit = (params = {}) => vm.$u.post(addressEditUrl, params);
	let addressAdd = (params = {}) => vm.$u.post(addressAddUrl, params);
	let addressDel = (params = {}) => vm.$u.post(addressDelUrl, params);
	
	let createOrder = (params = {}) => vm.$u.post(createOrderUrl, params);
	let updateOrderAddress = (params = {}) => vm.$u.post(updateOrderAddressUrl, params);
	let orderSubmit = (params = {}) => vm.$u.post(orderSubmitUrl, params);
	
	let payment = (params = {}) => vm.$u.post(paymentUrl, params);
	let orderList = (params = {}) => vm.$u.get(orderListUrl, params);
	let cancelOrder = (params = {}) => vm.$u.post(cancelOrderUrl, params);
	
	let rechangeMobileConfig = (params = {}) => vm.$u.get(rechangeMobileConfigUrl, params);
	let rechangeCreateOrder = (params = {}) => vm.$u.post(rechangeCreateOrderUrl, params);
	let rechangePayment = (params = {}) => vm.$u.post(rechangePaymentUrl, params);
	
	let myGroupOrder = (params = {}) => vm.$u.get(myGroupOrderUrl, params);
	
	// 此处使用了传入的params参数，一切自定义即可
	// let getInfo = (params = {}) => vm.$u.post(indexUrl, params);

	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		wechatInfoSave,
		wechatLogin,
		userInfoByToken,
		sendSms,
		mobileLogin,
		
		getGenerateLink,
		extOrderList,
		financeList,
		myTeam,
		poster,
		wechatBindMobile,
		withdrawal,
		withdrawalLog,
		bindAlipay,
		alipayInfo,
		bindMobile,
		goodsList,
		goodsInfo,
		classify,
		generateLink,
		goodsSearch,
		goodsSearchDetail,
		searchGenerateLink,
		shareImage,
		cashType,
		
		indexConfig,
		addressList,
		addressEdit,
		addressAdd,
		addressDel,
		
		createOrder,
		updateOrderAddress,
		orderSubmit,
		
		payment,
		orderList,
		
		cancelOrder,
		
		rechangeMobileConfig,
		rechangeCreateOrder,
		rechangePayment,
		
		myGroupOrder
	};
}

export default {
	install
}
